<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var str = "Google runoob taobao runoob";
    var n1 = str.match(/runoob/);   // 查找第一次匹配项
    var n2 = str.match(/runoob/g);  // 查找所有匹配项

    var str = "Google runoob taobao RUNoob";
    var n1 = str.match(/runoob/);   // 区分大小写
    var n2 = str.match(/runoob/i);  // 不区分大小写

    var str = "Google runoob taobao RUNoob";
    var n1 = str.match(/runoob/g);   // 区分大小写
    var n2 = str.match(/runoob/gi);  // 不区分大小写

    var str = "runoobgoogle\ntaobao\nrunoobweibo";
    var n1 = str.match(/^runoob/g);   // 匹配一个
    var n2 = str.match(/^runoob/gm);  // 多行匹配
    console.log(n1, n2);


    var s = 'aaa_aa_a';
    var r1 = /a+/g;
    var r2 = /a+/y;
    r1.exec(s) // ["aaa"]
    r2.exec(s) // ["aaa"]

    r1.exec(s) // ["aa"]
    r2.exec(s) // null


    var s = 'aaa_aa_a';
    var r = /a+_/y;
    r.exec(s) // ["aaa_"]
    r.exec(s) // ["aa_"]


  </script>
</body>

</html>